package rabbitmq.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Auther: liyanhao
 * @Description: 报警消费者
 * @Date: 2022/5/12 18:26
 * @Version: v1.0
 */
@Slf4j
@Component
public class WarningConsumer {
    public static final String WARNING_QUEUE_NAME = "warning_queue";

    //接受报警消息
    @RabbitListener(queues = WARNING_QUEUE_NAME)
    public void reveiveWarningMsg(Message message) {
        String msg = new String(message.getBody());
        log.error("报警发现不可路由消息:{}",msg);
    }
}
